package com.study.lickingdogweb.controller.demo;

import com.study.lickingdogcommon.annotation.log.Log;
import com.study.lickingdogserviceapi.serviceapi.model.request.DemoReq;
import com.study.lickingdogserviceapi.serviceapi.model.response.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

/**
 * Test Controller
 *
 * @Author suxiaoxiao
 * @Date 2019/5/12 3:39
 * @Version 1.0
 */
@RestController
@Slf4j
public class DemoController {

    @RequestMapping(value = "/demo", method = RequestMethod.POST)
    @Log(description = "demo controller")
    public String index(@RequestBody DemoReq demoReq) {
        log.info("参数是{}---{}", demoReq.getLogId(), demoReq.getName());
        return "hello" + demoReq.getName() + ", this is first message";
    }

    @RequestMapping(value = "/getUser", method = RequestMethod.GET)
    @Log(description = "实现了 Cacheable 的 getUser方法")
    @Cacheable(value="userinfo")
    public User getUser(@RequestParam String logId) {
        User user=new User("aa@126.com", "aa", "aa123456", "aa","123");
        System.out.println("若下面没出现“无缓存的时候调用”字样且能打印出数据表示测试成功");
        return user;
    }

}
